home *** CD-ROM | disk | FTP | other *** search
/ SGI Varsity Update 1998 August / SGI Varsity Update 1998 August.iso / dist / dist6.5 / il_dev.idb / usr / include / il / ilRotZoomImg.h.z / ilRotZoomImg.h
C/C++ Source or Header  |  1998-07-29  |  6KB  |  171 lines

  1. #if 0 
  2.  
  3.     Copyright (c) 1991 SGI   All Rights Reserved
  4.     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
  5.     The copyright notice above does not evidence any
  6.     actual or intended publication of such source code,
  7.     and is an unpublished work by Silicon Graphics, Inc.
  8.     This material contains CONFIDENTIAL INFORMATION that
  9.     is the property of Silicon Graphics, Inc. Any use,
  10.     duplication or disclosure not specifically authorized
  11.     by Silicon Graphics is strictly prohibited.
  12.     
  13.     RESTRICTED RIGHTS LEGEND:
  14.     
  15.     Use, duplication or disclosure by the Government is
  16.     subject to restrictions as set forth in subdivision
  17.     (c)(1)(ii) of the Rights in Technical Data and Computer
  18.     Software clause at DFARS 52.227-7013, and/or in similar
  19.     or successor clauses in the FAR, DOD or NASA FAR
  20.     Supplement.  Unpublished- rights reserved under the
  21.     Copyright Laws of the United States.  Contractor is
  22.     SILICON GRAPHICS, INC., 2011 N. Shoreline Blvd.,
  23.     Mountain View, CA 94039-7311
  24.  
  25. #endif
  26. /*
  27.     ilRotZoomImg performs image rotation, magnification and mirroring 
  28. */
  29.  
  30. #ifndef _ilRotZoomImg_h_
  31. #define _ilRotZoomImg_h_
  32.  
  33. #include <il/ilAffineWarp.h>
  34. #include <il/ilWarpImg.h>
  35.  
  36. #if defined(IL2_5_COMPAT)
  37.     #include <ifl/iflMinMax.h>
  38.     #include <ifl/iflOrientation.h>
  39. #endif
  40.  
  41. enum ilRotZoomImgParam {
  42.     ilRZIPcenter        = ilWarpImgParamLast<<1,
  43.     ilRZIPsizeToFit        = ilWarpImgParamLast<<2,
  44.     ilRZIPkeepAspect        = ilWarpImgParamLast<<3,
  45.     ilRZIPflipHorizontal    = ilWarpImgParamLast<<4,
  46.     ilRZIPflipVertical        = ilWarpImgParamLast<<5,
  47.     ilRotZoomImgParamLast   = ilRZIPflipVertical
  48. };
  49.  
  50.  
  51. class ilRotZoomLocker;
  52.  
  53. class ilRotZoomImg : public ilWarpImg {
  54. public:
  55.     iflClassListDeclare
  56.     // external api: begin
  57.  
  58.     ilRotZoomImg(ilImage* img = NULL, float rotAngle=0, 
  59.          float horizontalZoom=1, float verticalZoom=1,
  60.          ilResampType rs=ilNearNb);
  61.  
  62.     // rotate counter-clockwise about the rotation center (in degrees)
  63.     //
  64.     void setAngle(float ang);
  65.     float getAngle() { return angle; }
  66.  
  67.     // stretch horizontally and vertically
  68.     //
  69.     void setZoom(float horizontal, float vertical);
  70.     // external api: name=setUniformZoom
  71.     void setZoom(float zoom) { setZoom(zoom, zoom); }
  72.     void getZoom(float& horizontal, float& vertical) 
  73.     { resetCheck(); horizontal = zoom.x; vertical = zoom.y; }
  74.  
  75.     // set the image center to be h pixels to the right of the left
  76.     // image edge and v pixels up from the bottom edge (if the center
  77.     // flag is not set, then it defaults to the image center)
  78.     //
  79.     void setCenter(float h, float v);
  80.     void getCenter(float& h, float& v) 
  81.     { resetCheck(); h = center.x; v = center.y; }
  82.     void clearCenter();
  83.             
  84.     int isCenterSet() { return isSet(ilRZIPcenter); }
  85.  
  86.     // if the flip flags are non-zero then the image is flipped
  87.     // in the horizontal and vertical directions, respectively
  88.     //
  89.     void setHorizontalFlip(int flip=TRUE);
  90.     int getHorizontalFlip() { return isSet(ilRZIPflipHorizontal); }
  91.     void setVerticalFlip(int flip=TRUE);
  92.     int getVerticalFlip() { return isSet(ilRZIPflipVertical); }
  93.  
  94.     // if size-to-fit is set then the zoom values are adjusted in
  95.     // order to make the image fit a given width and height in pixels
  96.     //
  97.     void sizeToFit(float width, float height, int keepAspect=FALSE);
  98.     int isSizeToFit() { return isSet(ilRZIPsizeToFit); }
  99.     int isKeepAspect() { return isSet(ilRZIPkeepAspect); }    
  100.     void clearSizeToFit();
  101.     void clearKeepAspect();
  102.     
  103.     // external api: end
  104.  
  105.     #if defined(IL2_5_COMPAT)
  106.     // XXX C++ won't let us define one constructor for a class in terms
  107.     // XXX of another, so we have to duplicate the internal implementation
  108.     // XXX of the IL 3.0 ilRotZoomImg constructor here
  109.     ilRotZoomImg(ilImage* img, float rotAngle, float xzoom, float yzoom,
  110.              iflFlip flp, ilResampType rs=ilNearNb)
  111.         : ilWarpImg(img, rs)
  112.     {
  113.         if (img && iflOrientationIsTrans[img->getOrientation()])
  114.         ilError(MM_WARNING, "ilRotZoomImg with transposed image"
  115.             " now has lower-left semantics rotation, flip, etc.");
  116.  
  117.         const float minZoom = 1e-6;
  118.         angle = rotAngle;
  119.         zoom.init(iflMax(minZoom, xzoom), iflMax(minZoom, yzoom));
  120.         fit.init(0, 0);
  121.         setAllowed(ilRZIPcenter|ilRZIPsizeToFit|ilRZIPkeepAspect|
  122.                ilRZIPflipHorizontal|ilRZIPflipVertical);
  123.  
  124.         if (flp & iflXFlip) setHorizontalFlip(TRUE);
  125.         if (flp & iflYFlip) setVerticalFlip(TRUE);
  126.     }
  127.     #endif
  128.  
  129. private:
  130.     float angle;            // rotation angle in degrees
  131.     iflXYfloat zoom;            // zoom factor
  132.     iflXYfloat center;            // center of rotation
  133.     iflXYfloat fit;            // size to fit
  134.     
  135.     iflXYfloat normZoom;        // zoom factors in this orientation
  136.     float normAngle;            // rotation in this orientation
  137.     iflXYint normFlip;            // flip flags in this orientation
  138.     int trans;                // true if this orientation is transposed
  139.     
  140.     int optimize;                   // optimized case selector
  141.     int ntimes;                // does 2X zoom n times
  142.     iflOrientation optOrientation;  // orientation for mult-90 no-zoom case
  143.  
  144.     void initCoeff();
  145.     void resetOp();
  146.     void checkOptimize();
  147.     int ixs, iys, izs, ics;        // input page strides
  148.  
  149.  
  150.     // override ilWarpImg::prepareRequest for optimized cases
  151.     virtual ilMpCacheRequest *getMpRequest(ilMpManager* parent,
  152.                                            int x, int y, int z, int c,
  153.                                            int mode=ilLMread);
  154.  
  155.     virtual ilStatus prepareRequest(ilMpCacheRequest* req);
  156.     virtual ilStatus executeRequest(ilMpCacheRequest* req);
  157.     ilStatus mult90(ilMpCacheRequest* req);
  158.     ilStatus nearNbZoom(ilMpCacheRequest* req);
  159.     ilStatus initBizoom(ilMpCacheRequest* req);
  160.     ilStatus processBizoom(ilMpCacheRequest* req);
  161.     ilStatus process2XZoom(ilMpCacheRequest* req, void *src);
  162.     static ilStatus lockerDone(ilRotZoomLocker* rzcb, ilMpCallbackArg* mp);
  163.     ilStatus processPage(ilRotZoomLocker* req, ilLockRequest* page);
  164.     ilImageTile* getInputTileRequirement(const iflTile3Dint& tile, int c, int nc,
  165.                                          int* chans, int& inputTileCount);
  166.     
  167.     friend class ilRotZoomLocker;
  168. };
  169.  
  170. #endif
  171.